<?php
class ArrayDataHandle extends AbsDataHandle {
	private static $options = array();
	
	public static function getType() {
		return 'array';
	}
	
	public static function handle($defineCfg) {
		$options = (isset($defineCfg['options']) && is_array($defineCfg['options'])) ? $defineCfg['options'] : array();
		
		$options = array_merge(self::$options, $options);
		
		return self::genData($options);
	}
	
	private static function genData($options) {
		$data = array();
		$fields = (isset($options['fields']) && is_array($options['fields'])) ? $options['fields'] : array();
		foreach($fields as $field => $type) {
			$defineCfg = array(
				'type' => $type,
			);
			
			if(isset($options["field_{$field}"])) {
				$defineCfg['options'] = $options["field_{$field}"];
			}
			$data[$field] = DCenter::data($defineCfg, DCenter::getCfg());
		}
		
		return $data;
	}
}
?>